import { http } from '@/utils/http'

export const getChannels = () => {
  return async (dispatch) => {
    const res = await http.get('/channels')
    dispatch({
      type: 'article/getChannels',
      payload: res.data.data.channels,
    })
  }
}

export const getList = (params) => {
  return async (dispatch) => {
    const res = await http.get('/mp/articles', { params })
    dispatch({
      type: 'article/getList',
      payload: res.data.data,
    })
  }
}

export const delArticle = (id) => {
  return async () => {
    await http.delete(`/mp/articles/${id}`)
  }
}
